# -*- coding: utf-8 -*-

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask.ext.script import Manager,Shell
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.login import LoginManager, current_user
from flask_wtf.csrf import CsrfProtect

import os
import logging

basedir = os.path.abspath(os.path.dirname(__file__))
log_file_name = 'logging_file.txt'

logging.basicConfig(filename = os.path.join(basedir, log_file_name), \
    level = logging.INFO, filemode = 'a', \
    format = '%(asctime)s - %(levelname)s: %(message)s')
    
ccLog = logging
 
app = Flask(__name__)


csrf = CsrfProtect()

#csrf.init_app(app)
app.config.from_object('config')

db = SQLAlchemy(app)

manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)

login_manager = LoginManager()
login_manager.setup_app(app)
login_manager.session_protection = 'strong'
login_manager.login_view = 'login'

from app import views, models


